package luo.Controller;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import luo.entity.Flask;
import luo.utils.ApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @Description:
 * @Author:let_free
 * @Date:2024/6/6/11:14
 **/
@RestController
@Api(tags = "test1")
public class testController {
    @Autowired
    private Flask flask;
    @Autowired
    private ApiService apiService;


    @ApiOperation(value = "测试Post接口", notes = "这是一个测试用例")
    @PostMapping("/test")
    public String test() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("name", "luofan");
        map.put("age", "18");
//        testService.sendPost("http://localhost:8090/test", JSON.toJSONString(map));
        return apiService.postAPI("/test", map);
    }

    @ApiOperation(value = "测试Post接口", notes = "这是一个测试用例")
    @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Integer", dataTypeClass = Integer.class)
    @GetMapping("/getTest")
    public String getTest(@RequestParam Integer id) {
        HashMap<String, String> map = new HashMap<>();
        map.put("name", "luofan");
        map.put("age", "18");
        return map.toString();
    }

}
